#!/bih/sh

echo "请输入一个IPv4前缀,如202.117.128.0/20"
read IPv4P

#echo "$IPv4P" 
#awk -F. 'awk {print $1}' 
#b=`awk 'BEGIN {record=$IPv4P; print split("record", myarray, "/")}'`

b1=`echo "$IPv4P" | cut -f 1 -d "."`
b2=`echo "$IPv4P" | cut -f 2 -d "."`
b3=`echo "$IPv4P" | cut -f 3 -d "."`
b4=`echo "$IPv4P" | cut -f 4 -d "."`
b5=`echo "$b4" | cut -f 1 -d "/"`
b6=`echo "$b4" | cut -f 2 -d "/"`

IP1=`echo "obase=2; ibase=10; $b1"|bc`
IP2=`echo "obase=2; ibase=10; $b2"|bc`
IP3=`echo "obase=2; ibase=10; $b3"|bc`
IP4=`echo "obase=2; ibase=10; $b4"|bc`
IP5=`echo "obase=2; ibase=10; $b5"|bc`
IP6=`echo "obase=2; ibase=10; $b6"|bc`

#echo "$b1"

A=($b1 $b2 $b3 $b4 $b5 $b6)
#echo ${A[0]}
for ((i=0;i<6;i++));do
	echo ${A[i]}
done


#for ((i=0;i<6;i++));do
#	m=`echo "$"b$i`
#	echo "$m"	
#	n=$IP$i
#	ni=$n
#	echo "$mi" "$ni"
#done

#echo "$b2" "$IP2"
#echo "$b3" "$IP3"
#echo "$b4" 
#echo "$b5" "$IP4"
#echo "$b6" "$IP6"


